<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>
        <li>子节点1 首节点</li>
        <li>子节点2</li>
        <li>子节点2 尾结点</li>
    </ul>
    <button>修改首节点文字</button>
    <button>修改尾节点文字</button>
    <button>查看子节点2前的兄弟节点</button>
    <button>查看子节点2后的兄弟节点</button>
</body>
<script>
    window.onload = function (){
        let bu = document.getElementsByTagName('button');
        let uls = document.getElementsByTagName('ul')[0];
        bu[0].onclick = function(){
            uls.firstElementChild.innerHTML = '我是子节点1，我被修改了'
        }
        bu[1].onclick = function(){
            uls.lastElementChild.innerHTML = '我是尾结点，我被修改了'
        }
        bu[2].onclick = function(){
            alert(uls.children[1].previousElementSibling.innerHTML)
            // console.log(uls.children[1].previousElementSibling)
        }
        bu[3].onclick = function(){
            alert(uls.children[1].nextElementSibling.innerHTML)
        }

    }
</script>
</html>